//
//  RequestApi.h
//  MexicoLoan
//
//  Created by wxp on 2025/2/26.
//

#import <Foundation/Foundation.h>

@protocol RequestDelegate <NSObject>

@optional

@property (nonatomic, assign) BOOL isNotShowNoticeView;

- (void)protocolWillRequest;
- (void)protocolDidRequestSuccess;
- (void)protocolDidRequestFailure:(NSString *_Nullable) errorStr;

@end

NS_ASSUME_NONNULL_BEGIN

@interface RequestApi : NSObject

// post
+ (void)postUrl:(NSString *)URL
       delegate:(id <RequestDelegate> _Nullable)delegate
     parameters:(NSDictionary * _Nullable)parameters
        success:(void (^)(NSDictionary * response, id mark))success
        failure:(void (^)(NSString * errorStr, id mark))failure;

// get
+ (void)getUrl:(NSString *)URL
      delegate:(id <RequestDelegate> _Nullable)delegate
    parameters:(NSDictionary * _Nullable)parameters
       success:(void (^)(NSDictionary * response, id mark))success
       failure:(void (^)(NSString * errorStr, id mark))failure;

// post - All
+ (void)postUrl:(NSString *)URL
       delegate:(id <RequestDelegate> _Nullable)delegate
     parameters:(NSDictionary * _Nullable)parameters
      returnALL:(BOOL)returnAll
        success:(void (^)(NSDictionary * response, id mark))success
        failure:(void (^)(NSString * errorStr, id mark))failure;

// get - All
+ (void)getUrl:(NSString *)URL
      delegate:(id <RequestDelegate> _Nullable)delegate
    parameters:(NSDictionary * _Nullable)parameters
     returnALL:(BOOL)returnAll
       success:(void (^)(NSDictionary * response, id mark))success
       failure:(void (^)(NSString * errorStr, id mark))failure;

// 上传图片
+ (void)postUrl:(NSString *)URL
       delegate:(id <RequestDelegate> _Nullable)delegate
     parameters:(NSDictionary * _Nullable)parameters
constructingBodyWithBlock:(void (^)(id <AFMultipartFormData> formData))block
        success:(void (^)(NSDictionary * response, id mark))success
        failure:(void (^)(NSString * errorStr, id mark))failure;

// success
+ (void)requestSuccessDelegate:(id<RequestDelegate>)delegate responseDic:(NSDictionary *)responseDic success:(void (^)(NSDictionary * response, id mark))success;

// fail
+ (void)requestFailDelegate:(id<RequestDelegate>)delegate errorStr:(NSString *)strError errorCode:(NSString *)errorCode failure:(void (^)(NSString * errorStr, id mark))failure;

@end

NS_ASSUME_NONNULL_END
